package com.briup.jz.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountApply;
import com.briup.jz.service.AccountApplyService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description = "账户变动申请表（提现）相关接口")
@Validated
@RestController
@RequestMapping("/accountApply")
public class AccountApplyController {

	@Autowired
	private AccountApplyService accountApplyService;

	// 查询账户变动申请表信息
	@ApiOperation(value = "查询账户变动申请表信息(多条件查询！)")
	@GetMapping("query")
	@ApiImplicitParams({ @ApiImplicitParam(name = "AccountType", value = "申请类型（提现、充值）", paramType = "query"),
			@ApiImplicitParam(name = "status", value = "申请状态", paramType = "query"),
			@ApiImplicitParam(name = "userId", value = "用户id", paramType = "query") })
	public Message query(String AccountType, String status, Long userId) {
		List<AccountApply> list = accountApplyService.query(AccountType, status, userId);
		return MessageUtil.success(list);
	}

	// 保存或者更新
	@ApiOperation(value = "保存或更新资银行卡类信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "编号[更新的时候需要填写]", paramType = "form"),
			@ApiImplicitParam(name = "money", value = "充值金额", required = true, paramType = "form"),
			@ApiImplicitParam(name = "applyType", value = "申请类型[提现、充值]", required = true, paramType = "form"),
			@ApiImplicitParam(name = "status", value = "审核状态", required = true, paramType = "form"),
			@ApiImplicitParam(name = "userId", value = "操作用户id", required = true, paramType = "form"),
			@ApiImplicitParam(name = "reason", value = "不通过理由", required = true, paramType = "form") })
	@PostMapping("/saveOrUpdate")
	public Message saveOrUpdate(Long id, double money, String applyType, String status, Long userId, String reason) {
		AccountApply accountApply = new AccountApply();
		accountApply.setId(id);
		accountApply.setMoney(money);
		accountApply.setApplyType(applyType);
		accountApply.setStatus(status);
		accountApply.setUserId(userId);
		accountApply.setReason(reason);
		accountApplyService.saveOrUpdate(accountApply);
		return MessageUtil.success("操作成功");
	}

	// 删除一个id操作信息
	@ApiOperation(value = "删除银行账户信息")
	@PostMapping("/deleteById")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键", paramType = "query", required = true), })
	public Message deleteById(long id) {
		accountApplyService.deleteById(id);
		return MessageUtil.success("删除成功");
	}

}
